package com.cskaoyan.mall.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cskaoyan.mall.product.controller.PlatformAttributeController;
import com.cskaoyan.mall.product.converter.dto.PlatformAttributeInfoConverter;
import com.cskaoyan.mall.product.converter.dto.PlatformAttributeValueConverter;
import com.cskaoyan.mall.product.dto.PlatformAttributeInfoDTO;
import com.cskaoyan.mall.product.dto.PlatformAttributeValueDTO;
import com.cskaoyan.mall.product.mapper.PlatformAttrInfoMapper;
import com.cskaoyan.mall.product.mapper.PlatformAttrValueMapper;
import com.cskaoyan.mall.product.model.PlatformAttributeInfo;
import com.cskaoyan.mall.product.model.PlatformAttributeValue;
import com.cskaoyan.mall.product.query.PlatformAttributeParam;
import com.cskaoyan.mall.product.service.PlatformAttributeService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class PlatformAttributeServiceImpl implements PlatformAttributeService {
    @Autowired
    PlatformAttributeInfoConverter platformAttributeInfoConverter;

    @Autowired
    PlatformAttrInfoMapper platformAttrInfoMapper;
    @Override
    public List<PlatformAttributeInfoDTO> getPlatformAttrInfoList(Long firstLevelCategoryId, Long secondLevelCategoryId, Long thirdLevelCategoryId) {
        List<PlatformAttributeInfo> platformAttributeInfos = platformAttrInfoMapper.selectPlatFormAttrInfoList(firstLevelCategoryId, secondLevelCategoryId, thirdLevelCategoryId);
        List<PlatformAttributeInfoDTO> platformAttributeInfoDTOS = platformAttributeInfoConverter.platformAttributeInfoPOs2DTOs(platformAttributeInfos);
        return platformAttributeInfoDTOS;
    }

    @Override
    public void savePlatformAttrInfo(PlatformAttributeParam platformAttributeParam) {

    }

    @Override
    public PlatformAttributeInfoDTO getPlatformAttrInfo(Long attrId) {
        return null;
    }

    @Autowired
    PlatformAttributeValueConverter platformAttributeValueConverter;
    @Autowired
    PlatformAttrValueMapper platformAttrValueMapper;
    @Override
    public List<PlatformAttributeValueDTO> getPlatformAttrValueList(Long attrId) {
        LambdaQueryWrapper<PlatformAttributeValue> platformAttributeValueLambdaQueryWrapper = new LambdaQueryWrapper<>();
        platformAttributeValueLambdaQueryWrapper
                .eq(PlatformAttributeValue::getAttrId,attrId);
        List<PlatformAttributeValue> platformAttributeValues = platformAttrValueMapper.selectList(platformAttributeValueLambdaQueryWrapper);
        List<PlatformAttributeValueDTO> platformAttributeValueDTOS = platformAttributeValueConverter.platformAttributeValuePOs2DTOs(platformAttributeValues);
        return platformAttributeValueDTOS;
    }
}
